home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Devices and Hardware / SCSI / SCSI VBL Sample / AsyncSCSIPresent.c next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  1.7 KB  |  76 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        AsyncSCSIPresent.c
  3.  
  4.     Contains:    
  5.  
  6.     Written by: Martin Minow    
  7.  
  8.     Copyright:    Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/15/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23. #include <OSUtils.h>
  24. #include <Traps.h>
  25. #ifndef _SCSIAtomic
  26. /*
  27.  * This is needed if you don't have Universal Headers.
  28.  */
  29. #define _SCSIAtomic    0xA089
  30. #endif
  31.  
  32. Boolean                        AsyncSCSIPresent(void);
  33. static Boolean                TrapAvailable(
  34.         short                    theTrap
  35.     );
  36.  
  37. Boolean
  38. AsyncSCSIPresent(void)
  39. {
  40.         return (TrapAvailable(_SCSIAtomic));
  41. }
  42.  
  43. /*
  44.  * TrapAvailable (see Inside Mac VI 3-8)
  45.  */
  46. #define NumToolboxTraps() (                                \
  47.         (NGetTrapAddress(_InitGraf, ToolTrap)            \
  48.                 == NGetTrapAddress(0xAA6E, ToolTrap))    \
  49.             ? 0x200 : 0x400                                \
  50.     )
  51. #define GetTrapType(theTrap) (                            \
  52.         (((theTrap) & 0x0800) != 0) ? ToolTrap : OSTrap    \
  53.     )
  54.  
  55. static Boolean
  56. TrapAvailable(
  57.         short                    theTrap
  58.     )
  59. {
  60.         TrapType                trapType;
  61.         
  62.         trapType = GetTrapType(theTrap);
  63.         if (trapType == ToolTrap) {
  64.             theTrap &= 0x07FF;
  65.             if (theTrap >= NumToolboxTraps())
  66.                 theTrap = _Unimplemented;
  67.         }
  68.         return (
  69.             NGetTrapAddress(theTrap, trapType)
  70.             != NGetTrapAddress(_Unimplemented, ToolTrap)
  71.         );
  72. }
  73.  
  74.  
  75.  
  76.